package com.share.all.service;

import com.share.all.mapper.CityMapper;
import com.share.all.model.City;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author caifan
 * @created 2021/11/13
 * @description: 事务失效场景：https://mp.weixin.qq.com/s?__biz=MzkwNjMwMTgzMQ==&mid=2247490414&idx=1&sn=b232e8931fbc754a255bde93a5a810e5&chksm=c0ebc386f79c4a9079f096acc8e5836cab99746689309c293900488a538b7489dc7d64b0ae0a&token=751314179&lang=zh_CN&scene=21#wechat_redirect
 */
public abstract class AbsractCityService implements CityService {

    protected CityMapper cityMapper;

    protected RedisTemplate redisTemplate;

    /**
     * 测试 事务不生效 场景
     * @param city
     */
    @Transactional(rollbackFor = Exception.class)
    public void save(City city) {
        cityMapper.insert(city);
        int i = 1 / 0;
    }

}
